# Makefile

TARGET_DIR = /opt/STM/STLinux-2.2/devkit/sh4/target
STLINUX_DIR=/opt/STM/STLinux-2.4/devkit/sh4/bin/
INCDIR+= -I$(TARGET_DIR)/include
INCDIR+= -I$(TARGET_DIR)/usr/include
INCDIR+= -I$(TARGET_DIR)/usr/include/directfb
INCDIR+= -I$(TARGET_DIR)/usr/include/freetype2
INCDIR+= -I$(TARGET_DIR)/usr/local/include/freetype2
INCDIR += -Iinclude -I../../../include/
LIBDIR=-L../../../lib/
LIBS=-lplugapi

###########################
## Common compil options ##
###########################

OPTLEVEL = 2

CC       = $(STLINUX_DIR)sh4-linux-gcc
CFLAGS   = -w -c -O$(OPTLEVEL) -DST_7201  -DST_OSLINUX  -DARCHITECTURE_ST40
LD       = sh4-linux-ld
LEX      = flex
OBJ     := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
COBJ     := $(patsubst %.c,%.o,$(wildcard *.c))

INCLUDE  = -I.  $(INCDIR)

MAKEXE   = make
BINNAME  = ibox


DEFS     =

all: unix

clean:
	rm -f *.o ../../../bin/$(BINNAME) core

unix: $(COBJ) $(OBJ)
	$(STLINUX_DIR)sh4-linux-g++ -lfreetype -lcrypt -lpthread -lssl -lrt  -o  ../../../bin/$(BINNAME) $(COBJ) $(OBJ) $(LIBDIR) $(LIBS)
	$(STLINUX_DIR)sh4-linux-strip --strip-debug --strip-unneeded ../../../bin/$(BINNAME)

$(patsubst %.cpp,%.o,$(wildcard *.cpp)) : %.o : %.cpp
	$(CC) $(CFLAGS) -c $< $(INCLUDE) $(DEFS)

$(patsubst %.c,%.o,$(wildcard *.c)) : %.o : %.c
	$(CC) $(CFLAGS) -c $< $(INCLUDE) $(DEFS)

